const mongoose = require('mongoose')
const Schema = mongoose.Schema
// 实例化模板
const ProfileSchema = new Schema({
    user: {
        // 表与表的关联
        type: String,
        ref: "users",
        required: true
    },
    handle: {
        type: String,
        required: true,
        max: 40
    },
    company: {
        type: String,
    },
    website: {
        type: String,
    },
    location: {
        type: String,
    },
    status: {
        required: true,
        type: String,
    },
    skills: {
        type: [String], required: true,
    },
    bio: {
        type: String,
    },
    experienec: [
        {
            current: {
                type: Boolean,
                default: true
            },
            title: {
                type: String,
                required: true,
            },
            company: {
                type: String,
                required: true,
            },
            location: {
                type: String,

            },

            from: {
                type: String,
                required: true,
            },
            to: {
                type: String,
            },
            description: {
                type: String,
                required: true,
            },
        }
    ],
    education: [
        {
            current: {
                type: Boolean,
                default: true
            },
            school: {
                type: String,
                required: true,
            },
            degree: {
                type: String,
                required: true,
            },
            filedostudy: {
                type: String,

            },

            from: {
                type: String,
                required: true,
            },
            to: {
                type: String,
            },
            description: {
                type: String,
                required: true,
            },
        }
    ],
    social: {
        wechart: {
            type: String,
        },
        QQ: {
            type: String,
        },
        tengxunkt: {
            type: String,
        },
        wangyikt: {
            type: String,
        },
    },
    githubusername: {
        type: String,
    },
    date: {
        type: Date,
        default: Date.now
    },
})

module.exports = Profile = mongoose.model('profile', ProfileSchema)